<template>
  <a-card hoverable :bordered="false" :style="{ width: '100%', marginBottom: '10px' }">
    <div class="zytx">
      <div class="zytx_title">
        <div class="zytx_title_left">重要提醒</div>
        <div>
          <div class="btn">一键已读</div>
        </div>
      </div>
      <a-spin :loading="loading" style="width:100%;">
        <a-scrollbar style="height:345px;overflow: auto;"  v-if="list.length > 0">
          <div class="zytx_item" v-for="(item, i) in list" :key="i">
            <div v-for="(item, i) in list" :key="i" class="zytx_item">
            <div class="zytx_item_data">
                <!-- <div>
                            <div style="display:flex; align-items:center;">
                                <div class="zytx_item_tag_round"></div>
                                <span class="zytx_item_tag_red">合约到期</span>
                            </div>
                        </div> -->
                <div style="flex: 1">{{ item.title }}</div>
            </div>
            <div class="zytx_item_time">{{ item.create_at }}</div>
            </div>
          </div>
        </a-scrollbar>
        <div v-else style="display:flex; align-items:center; height: 350px">
          <a-empty />
        </div>
      </a-spin>
      <div style="display:flex;align-items:center; height:20px;">
        <div style="flex:1; font-size:16px; color:#000;">共{{total}}条消息</div>
        <div style="display:flex;align-items:center;">
            <icon-left-circle style="font-size:20px; color:#68C1B2;" @click="pre"/>
            <div style="font-size:16px; margin:0 6px;"> {{searchForm.page}}/{{totalPage}} </div>
            <icon-right-circle style="font-size:20px; color:#68C1B2;" @click="next"/>
        </div>
      </div>
    </div>
  </a-card>
</template>
<script setup>
import { ref, onMounted, reactive } from "vue";
import syApi from "@/api/home/sy";
const loading = ref(false);
const list = ref([]);
const searchForm = reactive({
    page: 1,
    pageSize: 10,
    read_status: 'all',
    content_type: 'all',
});
onMounted(() => {
    getZytxListPage();
});
const total = ref(0);
const totalPage = ref(0);
const pre = () => {
  if (searchForm.page == 1) {
    return;
  }
  searchForm.page--;
  getZytxListPage();
};
const next = () => {
  if (searchForm.page >= totalPage.value) {
    return;
  }
  searchForm.page++;
  getZytxListPage();
};
const getZytxListPage = () => {
  loading.value = true;
  syApi
    .getZytxListPage(searchForm)
    .then((res) => {
      if (res.code == 200 && res.success) {
        let items = res.data.items;
        list.value = items;
        // list.value = [{}];
        total.value = res.data.pageInfo.total;
        totalPage.value = res.data.pageInfo.totalPage;
      }
      loading.value = false;
    })
    .catch((e) => {
      console.error(e);
      loading.value = false;
    });
};
</script>
<style scoped lang="less">
.zytx_title {
  display: flex;
  align-items: center;
  height:40px;
  .zytx_title_left {
    flex: 1;
    font-family: PingFang SC;
    font-weight: 700;
    font-size: 16px;
    line-height: 100%;
    letter-spacing: 0px;
    color: #000000;
    padding: 2px 10px;
    border-left: 5px solid #68C1B2;
  }
  .btn {
    width: 68;
    height: 28;
    gap: 10px;
    padding-right: 10px;
    padding-left: 10px;
    border-radius: 99px;
    border-width: 1px;
    background: #68C1B226;
    border: 1px solid #68C1B2;
    color: #68C1B2;
  }
}

.zytx_item {
  width: 100%;
  padding: 10px 0;
  .zytx_item_data {
    font-family: PingFang SC;
    font-weight: 400;
    font-size: 14px;
    line-height: 100%;
    letter-spacing: 0px;
    color: #000000;
    line-height: 20px;
    margin-bottom: 10px;
    display: flex;
    .zytx_item_tag_red {
      padding: 0px 8px;
      color: #eb1f29;
      background: #eb1f2926;
      border: 1px solid #eb1f29;
      margin-right: 10px;
      font-size: 12px;
    }
    .zytx_item_tag_round {
      width: 6px;
      height: 6px;
      border-radius: 6px;
      background: #eb1f29;
      margin-right: 6px;
    }
  }
  .zytx_item_time {
    font-family: PingFang SC;
    font-weight: 400;
    font-size: 12px;
    line-height: 100%;
    letter-spacing: 0px;
    color: #9c9c9c;
  }
}
.zytx_item + .zytx_item {
  border-top: 1px solid #00000026;
}
</style>
